package de.tum.in.eist.poll.shared.service;

import java.util.ArrayList;
import java.util.Date;

import com.google.gwt.user.client.rpc.AsyncCallback;

import de.tum.in.eist.poll.shared.Feedback;
import de.tum.in.eist.poll.shared.Lecture;
import de.tum.in.eist.poll.shared.User;

public interface PollServiceAsync {

	/**
	 * Make an asynchronous login request per RPC.
	 * @see PollService#login(String, String)
	 * @param email - email of the user trying to login
	 * @param pass - password of the user trying to login
	 * @param callback - {@link AsyncCallback} object to manage the response
	 * @throws IllegalArgumentException in case of wrong email or password
	 */
	public void login(String email, String pass, AsyncCallback<User> callback) throws IllegalArgumentException;
	
	/**
	 * asynchronously save new lecture on the server.
	 * @param user - user who want to create the lesson
	 * @param topic - topic of new lecture
	 * @param date - date of lecture
	 * @param callback - {@link AsyncCallback} object to manage the response
	 * @return the saved lecture
	 * @throws IllegalArgumentException if user is not a lecturer
	 */
	void addNewLecture(User user, String topic, Date date,
			AsyncCallback<Lecture> callback);

	/**
	 * post a feedback about a lecture.
	 * @param user - student who posts the feedback
	 * @param lecture - lecture about which belongs to the feedback
	 * @param feedback - feedback containing the rating and optional the opinions
	 * @param callback - {@link AsyncCallback} object to manage the response
	 * @return {@link Lecture} object containing this feedback
	 * @throws Exception - if the user already gave a feedback about this lecture or the user is a lecturer
	 */
	void postFeedback(User user, Lecture lecture, Feedback feedback,
			AsyncCallback<Lecture> callback);

	/**
	 * Make a login request using the sessionID.
	 * @param sessionID - string containing 
	 * @param callback - {@link AsyncCallback} object to manage the response
	 * @return {@code User} object that belongs to this sessionID
	 */
	void login(String sessionID, AsyncCallback<User> callback);
	
	/**
	 * get list of updated lectures (stats changed).
	 * @param user - user making the request
	 * @param start - start date
	 * @param stop - end date
	 * @return the lecture objects containing additional feedback informations.
	 */
	void requestLecturesInRange(User user, Date start, Date stop,
			AsyncCallback<ArrayList<Lecture>> callback);

	/**
	 * get list of lectures of this week.
	 * @param user - user making the request
	 * @return the lecture objects containing additional feedback informations.
	 */
	void requestLecturesOfCurrentWeek(User user,
			AsyncCallback<ArrayList<Lecture>> callback);

	/**
	 * get list of lectures of last week.
	 * @param user - user making the request
	 * @return the lecture objects containing additional feedback informations.
	 */
	void requestLecturesOfLastWeek(User user,
			AsyncCallback<ArrayList<Lecture>> callback);

	/**
	 * get list of updated lectures (stats changed).
	 * @param user - user making the request
	 * @return the lecture objects containing additional feedback informations.
	 */
	void requestUpdatedLectures(User user,
			AsyncCallback<ArrayList<Lecture>> callback);

	void requestLecturesOfCurrentSemester(User user,
			AsyncCallback<ArrayList<Lecture>> callback);

	void register(String email, String pass, AsyncCallback<User> callback);

	void addMultipleNewLectures(User user, String topic, Date startdate,
			Date enddate, AsyncCallback<ArrayList<Lecture>> callback);

	
}
